<template>
    <view>
        <web-view :src="data.chatlink"></web-view>
    </view>
</template>

<script>
import { Company } from './company-model.js';
var company = new Company(); //实例化 首页 对象
export default {
    data() {
        return {
            id: 0,
            title: '',
            tel: '',
            pid: 1,
            isgz: 0,
            title: '',
            activeCategoryId: '',

            data: {
                chatlink: ''
            },

            joblist: '',
            companyimglist: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (e) {
        this.onLoadClone3389(e);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        uni.showNavigationBarLoading();
        this.onLoadClone3389({});
    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        var that = this;
        return {
            title: that.title,
            path: '/pages/companydetail/index?id=' + that.id
        };
    },
    methods: {
        /**
         * 生命周期函数--监听页面加载
         */
        onLoadClone3389: function (e) {
            var that = this;
            if (that.id > 0) {
                var id = that.id;
            } else {
                var id = e.id;
                that.id = e.id;
            }
            uni.showShareMenu({
                withShareTicket: true,
                menus: ['shareAppMessage', 'shareTimeline']
            });
            that.setData({
                activeCategoryId: that.pid
            });
            var params = {
                id: that.id
            };
            company.getCompanyDetailData((data) => {
                uni.setNavigationBarTitle({
                    title: data.companyinfo.companyname
                });
                that.title = data.companyinfo.companyname;
                that.isgz = data.companyinfo.isgz;
                that.setData({
                    data: data.companyinfo,
                    isgz: that.isgz,
                    joblist: data.joblist,
                    companyimglist: data.companyinfo.companyimg
                });
                uni.hideNavigationBarLoading(); //完成停止加载
                uni.stopPullDownRefresh();
            }, params);
        },

        tabClick: function (e) {
            var pid = e.currentTarget.id;
            var that = this;
            that.pid = pid;
            that.setData({
                activeCategoryId: pid
            });
        },

        toJobDetail: function (e) {
            var id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/pages/jobdetail/index?id=' + id
            });
        },

        toGz: function (e) {
            var that = this;
            var companyid = that.id;
            var params = {
                companyid: that.id
            };
            company.gzCompany((data) => {
                if (data.status == 0) {
                    that.isgz = 1;
                    that.setData({
                        isgz: 1
                    });
                    uni.showToast({
                        title: data.msg,
                        icon: 'success',
                        duration: 2000
                    });
                } else {
                    that.isgz = 0;
                    that.setData({
                        isgz: 0
                    });
                    uni.showToast({
                        title: data.msg,
                        icon: 'success',
                        duration: 2000
                    });
                }
            }, params);
        }
    }
};
</script>
<style>
/* pages/wechat/index.wxss */
</style>
